//
//  LSZHelpLogListViewController.m
//  PartyClassCloud
//
//  Created by 梁素珍 on 2018/12/1.
//  Copyright © 2018年 九酷. All rights reserved.
//

#import "LSZHelpLogListViewController.h"

@interface LSZHelpLogListViewController ()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic,strong) UITableView * helpLogListTableView;
@property(nonatomic,strong) LSZIndustryManager * industryManager;
@end

@implementation LSZHelpLogListViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"帮扶日志";
    [self getHelpLogList];
    [self.helpLogListTableView registerClass:[LSZDocumentdetailsCell class] forCellReuseIdentifier:@"LSZDocumentdetailsCell"];
}
-(void)getHelpLogList
{
    [LSZRequestDicData accessToHelpLogsForPoorHouseholds:self.householdId :^(BOOL isOK, NSString * string, LSZIndustryManager * industryManager) {
        if (isOK == YES) {
            self.industryManager = industryManager;
            [self.helpLogListTableView reloadData];
        }else{
            if ([string isEqualToString:@"重复登录"]) {
                [LSZPublicClassDataToll RepeatLoginInterfaceJump:self.view fromVC:@"LSZLiteratureViewController"];
            }else{
                [LSZPublicClassDataToll initWithAlertKuangView:self.view string:string];
            }
        }
    }];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.industryManager.arrayData.count;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 100;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 0.001;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    LSZDocumentdetailsCell * cell = [tableView dequeueReusableCellWithIdentifier:@"LSZDocumentdetailsCell" forIndexPath:indexPath];
    if(self.industryManager.arrayData.count >indexPath.row){
        LSZIndustryMg * industryMg = nil;
        industryMg = self.industryManager.arrayData[indexPath.row];
        cell.labelBrowse.hidden = YES;
        cell.imageViewBrowse.hidden = YES;
        [cell.imageViewIcon sd_setImageWithURL:[NSURL URLWithString:industryMg.coverUrl] placeholderImage:[UIImage imageNamed:@"默认"]];
        cell.labelTitle.text = industryMg.personNames;
        cell.labelTime.text = industryMg.publishTime;
        CGRect rect = cell.labelTime.frame;
        rect.origin.x = CGRectGetMinX(cell.labelTitle.frame);
        cell.labelTime.frame = rect;
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(self.industryManager.arrayData.count >indexPath.row){
        LSZIndustryMg * industryMg = nil;
        industryMg = self.industryManager.arrayData[indexPath.row];
        LSZHelpLogDetailsViewController * VC = [[LSZHelpLogDetailsViewController alloc]init];
        VC.industryMg = industryMg;
        [self.navigationController pushViewController:VC animated:YES];
    }
}
-(UITableView *)helpLogListTableView
{
    if (_helpLogListTableView == nil) {
        _helpLogListTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.width , [[UIScreen mainScreen] bounds].size.height) style:UITableViewStyleGrouped];
        _helpLogListTableView.delegate = self;
        _helpLogListTableView.dataSource = self;
        _helpLogListTableView.estimatedRowHeight=0;
        _helpLogListTableView.estimatedSectionFooterHeight =0;
        _helpLogListTableView.estimatedSectionHeaderHeight =0;
        [_helpLogListTableView setSeparatorInset:UIEdgeInsetsMake(0, 20, 0, 20)];
        [self.view addSubview:_helpLogListTableView];
    }
    return _helpLogListTableView;
}

@end
